import QtQuick 2.9
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.12

ToolBar {
    id: root

    signal clickedBack()

    property alias canBack: btnBack.visible
    property alias title: txtTitle.text

    //......................
    Rectangle {
        anchors.fill: parent
        gradient: Gradient {
            GradientStop { position: 0.0; color: "#cc9999" }
            GradientStop { position: 1.0; color: "#cc8888" }
        }
    }

    RowLayout {
        anchors.fill: parent
        anchors.leftMargin: 9
        anchors.rightMargin: 9
        ToolButton {
            id: btnBack
            text: qsTr("‹")
            font.pixelSize: parent.height * 0.65
            onClicked: clickedBack()
        }
        Label {
            id: txtTitle
            text: "Title"
            font.pixelSize: parent.height * 0.45
            elide: Label.ElideRight
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
            Layout.fillWidth: true
        }
        ToolButton {
            text: qsTr("≡") //⋮
            font.pixelSize: parent.height * 0.65
            onClicked: {
                popMenu.open()
            }

            Menu {
                id: popMenu
                title: qsTr("Menu")
                topMargin: parent.height + 5
                rightMargin: 5

                MenuItem {
                    id: actionExit
                    text: qsTr("退出")
                    onTriggered: {
                        logout()
                    }
                }

                MenuItem {
                    text: qsTr("关于")
                    onTriggered: {
                        showAboutDialog()
                    }
                }
            } //menu
        }

    }
} //header
